﻿using System.Windows;

namespace Oxage.Services
{
	public class SimulatorService
	{
		public static SimulatorWindow Window
		{
			get;
			set;
		}

		public static void ShowWindow()
		{
			if (Window == null)
			{
				Window = new SimulatorWindow();
				Window.Unloaded += (sender, e) => Window = null;
			}
			Window.Show();
		}

		public static void Refresh()
		{
			string content = App.ViewModel.Document.Content;

			if (Window != null)
			{
				Window.ViewModel.QuickDraw(content);
			}

			App.ViewModel.View.Simulator.ViewModel.QuickDraw(content);
		}

		public static void Clear()
		{
			if (Window != null)
			{
				Window.ViewModel.Clear();
			}

			App.ViewModel.View.Simulator.ViewModel.Clear();
		}
	}
}
